package cn.stylefeng.guns.cp;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.compress.utils.Lists;

import java.io.File;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @Description TODO
 * @Author xiesm
 * @Date 2023/12/21 10:43
 **/
public class Sc {

    public static void main(String[] args) {
        readResult1000();
    }

    //读取近千结果
    public static void readResult1000() {
        String str = FileUtil.readString("D:\\home\\code\\极速赛车\\近1000.txt", Charset.defaultCharset());
        JSONObject jsonObject = JSONObject.parseObject(str);
        JSONArray datas = jsonObject.getJSONArray("data");
        List<List<String>> rows = Lists.newArrayList();
        for (int i = 0; i < datas.size(); i++) {
            List<String> result = Lists.newArrayList();

            JSONObject data = datas.getJSONObject(i);
            String issue = data.getString("issue");
            result.add(issue);

            String[] codes = data.getString("code").split(" ");
            for (int j = 0; j < codes.length; j++) {
                String code = StrUtil.padPre(codes[j], 2, "0");
                result.add(code);
            }
            rows.add(result);
        }
        ExcelWriter writer = ExcelUtil.getWriter(new File("D:\\home\\code\\极速赛车\\result.xls"));
        writer.write(rows);
        writer.flush();
        writer.close();
    }

    public static boolean checkResult(int num, String code) {
        boolean boo = false;

        return boo;
    }
}
